﻿@using System.Globalization
@model ProductDetailsModel.ProductPriceModel
@inject IWorkContextAccessor workContextAccessor

<div class="prices d-flex justify-content-center align-items-start row px-3 flex-column" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    @if (Model.EnteredPrice)
    {
        @*Display empty space*@
    }
    else if (Model.CallForPrice)
    {
        <div class="product-price call-for-price col-12 px-0">
            <b-button v-b-modal.modal-1>@Loc["Products.CallForPrice"]</b-button>
            <b-modal id="modal-1" hide-footer title="@Loc["Products.CallForPrice"]">
                <p class="my-4">
                    <span>@Loc["Products.CallForPrice"]:</span><a href="tel:@workContextAccessor.WorkContext.CurrentStore.CompanyPhoneNumber"> @workContextAccessor.WorkContext.CurrentStore.CompanyPhoneNumber</a>
                </p>
            </b-modal>
        </div>
    }
    else
    {
        if (Model.IsReservation)
        {
            <div class="rental-price mb-2">
                <label class="mb-0">@Loc["Products.Price.ReservationPrice"]:</label>
                <span>@Model.ReservationPrice</span>
            </div>
        }

        if (Model.IsAuction)
        {
            <div class="actual-price">
                @if (Model.HighestBidValue > 0)
                {
                    <label class="mb-0">@Loc["Products.Price.CurrentPrice"]:</label>
                    <span>@Model.HighestBid</span>
                }
                else
                {
                    <label class="mb-0">@Loc["Products.Price.StartPrice"]:</label>
                    <span>@Model.StartPrice</span>
                }
            </div>
        }

        if (!string.IsNullOrWhiteSpace(Model.CatalogPrice))
        {
            <div class="catalog-product-price col-12 px-0 mb-2">
                <label class="col-form-label mb-0">@Loc["Products.Price.CatalogPrice"]:</label>
                <span class="h6 mb-0">@Model.CatalogPrice</span>
            </div>
        }

        if (!(Model.IsAuction && Model.DisableBuyButton))
        {
            <div class="@if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount)) { <text>product-price col-12 px-0 d-inline-flex align-items-center</text> }else { <text>non-discounted-price col-12 px-0 d-flex align-items-center</text> }">
                <span class="price-value-@(Model.ProductId) @if (string.IsNullOrEmpty(Model.PriceWithDiscount)) { <text>actual-price</text> }">
                    <strong>@Html.Raw(Model.Price)</strong>
                    @if (!string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
                    {
                        <div class="d-inline-flex align-items-center product-price discounted-price col-12 px-0">
                            <label class="mb-0 mx-2">@Loc["Products.Price.WithDiscount"]:</label>
                            <strong class="actual-price">@Html.Raw(Model.PriceWithDiscount)</strong>
                        </div>
                    }
                    <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" class="your-price price-value-@(Model.ProductId)"/>
                </span>
                @if (!string.IsNullOrWhiteSpace(Model.OldPrice))
                {
                    <div class="old-product-price">
                        <span class="old-price mx-2">@Model.OldPrice</span>
                    </div>
                }

            </div>
        }
        else
        {
            @if (!string.IsNullOrWhiteSpace(Model.OldPrice))
            {
                <div class="old-product-price">
                    <span class="old-price mx-2">@Model.OldPrice</span>
                </div>
            }
        }

        if (!string.IsNullOrEmpty(Model.BasePricePAngV))
        {
            <div class="base-price-pangv ml-2">
                @Model.BasePricePAngV
            </div>
        }

        if (!string.IsNullOrEmpty(Model.CurrencyCode))
        {
            <meta itemprop="priceCurrency" content="@Model.CurrencyCode"/>
        }

        @if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
        {
            <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)"/>
        }
    }
</div>